package com.blog.kit;

import java.util.regex.Pattern;

/**
 * 加密工具类
 * <p>
 * Created by wangjian on 16/9/14.
 */
public class RegexKit {

    public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_FORMAT = "yyyy-MM-dd";
    public static final String FLOAT = "(^([1-9][0-9]{0,10})(\\.[0-9]{0,2})?$)|([0].[0-9]{0,2})";
    public static final String INTEGER = "^[1-9][0-9]*";
    public static final String POSTCODE = "^[0-9]{6}$";
    public static final String MOBILE = "^[+]?[0-9]{0,4}1[3|4|5|7|8][0-9]{9}$";
    public static final String EMAIL = "\\b(^[\'_A-Za-z0-9-]+(\\.[\'_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z0-9]{2,})|(\\.[A-Za-z0-9]{2,}\\.[A-Za-z0-9]{2,}))$)\\b";
    public static final String ID_CARD = "^\\d{15}$|^\\d{17}([0-9]|X)$";

    public static boolean match(String regex, String str) {

        return Pattern.compile(regex).matcher(str).matches();
    }

    public static boolean notMatch(String regex, String str) {

        return !match(regex, str);
    }
}
